/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;


/**
 *
 * @author Jacek
 */
public class Server {

    /**
     * @param args the command line arguments
     */
    ClientsColector clients;
    ServerSocket listing;
    Socket newConnection;
    Client newClient;
    public Server() {
        clients=new ClientsColector();
        listing=null;
        newConnection=null;
        newClient=null;
    
    }
    public void Start(int port) throws IOException{
        listing = new ServerSocket(port);
         while(true){
                newConnection = listing.accept();
                newClient=new Client("unknown");
                newClient.setActive(newConnection);
                clients.Add(newClient);  
         }
    }
    public static void main(String[] args){  
        try {
            Server server=new Server();
            server.Start(Integer.parseInt(args[0]));
        } catch (IOException ex) {
            System.out.print(ex.getMessage());
        }
        catch(Exception ex){
            System.out.print(ex.getMessage());
        }
        
    }
}

